using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
    public class tbCTDiaDiemBUS
    {
        public static void Insert(tbCTDiaDiem ctdiadiem)
        {
            tbCTDiaDiemDAL ctddDAL = new tbCTDiaDiemDAL();
            ctddDAL.Insert(ctdiadiem);
        }
        public static void Update(tbCTDiaDiem ctdiadiem)
        {
            tbCTDiaDiemDAL ctddDAl = new tbCTDiaDiemDAL();
            ctddDAl.Update(ctdiadiem);
        }
        public static void Delete(int iD)
        {
            tbCTDiaDiemDAL ctddDAl = new tbCTDiaDiemDAL();
            ctddDAl.Delete(iD);
        }
        public static tbCTDiaDiemCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbCTDiaDiemDAL ctddDAL = new tbCTDiaDiemDAL();
            return ctddDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCTDiaDiemCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTDiaDiemDAL ctddDAL = new tbCTDiaDiemDAL();
            return ctddDAL.Get(cri.Criter, 0, 0, tbCTDiaDiemColumns.diadiem.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbCTDiaDiem GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbCTDiaDiemColumns.diadiem.ToString(), Condition.EQUAL, iD);
            tbCTDiaDiemDAL ctddDAL = new tbCTDiaDiemDAL();
            tbCTDiaDiemCollection ctddCollection = ctddDAL.Get(cri.Criter, 0, 0, tbCTDiaDiemColumns.diadiem.ToString(), OrderDirection.ASC.ToString(), out total);
            if (ctddCollection.Count > 0)
                return ctddCollection[0];
            return null;
        }
        public static tbCTDiaDiemCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTDiaDiemDAL ctddDAL = new tbCTDiaDiemDAL();
            return ctddDAL.Get(cri.Criter, 1, number, tbCTDiaDiemColumns.diadiem.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbCTDiaDiemCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTDiaDiemDAL ctddDAL = new tbCTDiaDiemDAL();
            return ctddDAL.Get(cri.Criter, 1, number, tbCTDiaDiemColumns.diadiem.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
